/*
 * @lc app=leetcode.cn id=1518 lang=javascript
 *
 * [1518] 换酒问题
 */

// @lc code=start
/**
 * @param {number} numBottles
 * @param {number} numExchange
 * @return {number}
 */
var numWaterBottles = function (numBottles, numExchange) {
  let res = numBottles;
  while (numBottles >= numExchange) {
    res += numBottles / numExchange >>> 0;
    numBottles = numBottles % numExchange + numBottles / numExchange >> 0;
  }
  return res;
};
// @lc code=end

